<?
function printouttable($result){
	echo '<table border="1">';
	$first = true;
	while($row=$result->fetch(SQLITE_ASSOC)){
		echo '<tr>';
		if($first){
			foreach($row as $key=>$r){
				echo '<td>'.$key.'</td>';
			}
			echo '</tr><tr>';
			$first = false;
		}
		foreach($row as $key=>$r){
			echo '<td>'.$r.'</td>';
		}
		echo '</tr>';
	}
	echo '</table>';
}


$db=new SQLiteDatabase("../db/mandi");

$table = $_GET['table'];

if($table){
	echo $table.'<BR>';
	$result=$db->query("select * from ".$table);
	printouttable($result);
} else {
	echo 'PRODUCT_TABLE<BR>';
	$result=$db->query("select * from product_table");
	printouttable($result);

	echo '<br><br>LICENSES<BR>';
	$result=$db->query("select * from licenses");
	printouttable($result);

	echo '<br><br>EMPLOYEES<BR>';
	$result=$db->query("select * from employees");
	printouttable($result);
	
	echo '<BR><BR>ENTRY_TABLE<BR>';
	$result=$db->query("select * from entry_table");
	printouttable($result);

	echo '<BR><BR>SALE_TABLE<BR>';
	$result=$db->query("select * from sale_table");
	printouttable($result);
}


?>